#+TITLE: Fantasy Vacation Planner
#+AUTHOR: Zelphir
#+STARTUP: content indent align inlineimages hideblocks entitiesplain nologdone nologreschedule nologredeadline nologrefile
#+TODO: TODO INPROGRESS | DONE
#+DATE: <2021-01-16 Sa>
#+LANGUAGE: English
#+PRIORITIES: A E E
#+OPTIONS: ^:{} H:10 toc:2
#+OPTIONS: tags:nil
#+OPTIONS: tasks:nil
#+OPTIONS: toc:nil
#+OPTIONS: H:6
#+OPTIONS: p:nil
#+OPTIONS: pri:nil
#+OPTIONS: prop:nil
#+OPTIONS: todo:nil
#+OPTIONS: stat:nil
#+OPTIONS: |:t
#+OPTIONS: inline:nil

* Fantasy Vacation Planner

This project contains a program for simulating an imaginary vacation trip.

* Dependencies

The program depends on the following software:

+ GNU Guile 3.0.4 -- Earlier versions not tested, but the program is not using anything special, so probably an earlier version will work just fine, as long as the other required libraries exist for that earlier version.
+ ~guile-json~ of GNU Guix commit (revision) ~8518a3692cbb9cd96d69c03e9de9ad6fdcfebbee~ -- Other versions were not tested. However, the program does not use advanced features of the library, so other versions will probably work fine as well.

** Potential dependencies

+ The provided GNU Guix environment specification depends on GNU Guix being installed.

* Usage

Clone the repository using:

#+begin_src shell
git clone --recurse-submodules --remote-submodules URL
#+end_src

Or, if you are using an older version of ~git~:

#+begin_src shell
git clone URL
cd DIR_OF_REPO
git submodule update --init --recursive
#+end_src

A GNU Guix environment setup script is provided in ~guix-env/env.bash~. You can run it using GNU Bash from the root directory of the cloned repository:

#+begin_src shell
bash guix-env/env.bash
#+end_src

After which you will have the required libraries to run the program. You can run the program from the root directory of this project as follows:

#+begin_src shell
guile -L '.' -L 'lib/fslib' -L 'lib/guile-user-input-output' --fresh-auto-compile main.scm
#+end_src

Alternatively, you can mke use of the provided GNU Bash script in the root directory of the cloned repostitory:

#+begin_src shell
bash start.bash
#+end_src

If you do not have GNU Guix installed, you need to consult the list of dependencies and make sure you got them satisfied, before running the program.

** Configuration files

Events that can occur while travelling as well as the difficulty of the journey are specified in ~config/transportation/*.json~ files.

Other than that here is a list of configuration files, and their corresponding schemas:

- general settings
  - files: ~config/general.json~
  - schema: ~config/schema/general-schema.json~
  - description: This file contains general settings like the difficulty and how much influence karma has in the game.
- player configuration
  - files: ~config/player/*.json~
  - schema: ~config/schema/player-schema.json~
  - description: This file is named after the player. The file name without its extension will be the name of the player in the game. It contains the route the player travels.
- events:
  - files: ~config/transportation/*.json~
  - schema: ~config/schema/transportation-schema.json~
  - description: These files are named after the means of transportation, for which non-default events are defined. There is also a ~default.json~, which specifies the default events, which can happen, when there is no configuration for a means of transportation, which the player has chosen to use in their player configuration. Each transportation configuration file contains events and possible actions after events happen. Events have probabilities and actions have karma among other attributes.

** Validating the configuration files

There are JSON schemas given for configuration files as ~...-schema.json~. To make use of them, you may use any program you want to use for validating the configuration files against their corresponding JSON schema. A little Python 3 program is given in ~validate.py~, which validates using the ~jsonschema~ library from PyPI. To use it do the following:

1. Run ~bash python-env/env.bash~ from the root directory of this project, to create a Python venv.
2. Run ~source python-env/venv/bin/activate~ to activate the venv.
3. Run the validation program using ~python3 validate.py~.
